package mortal.game.resource
{
	import __AS3__.vec.*;
	import com.gengine.resource.*;
	import flash.utils.*;
	import mortal.game.resource.info.*;
	
	public class GameDefConfig extends Object
	{
		private var _data:Dictionary;
		private var _xmlDic:Dictionary;
		private static var _instance:GameDefConfig;
		private static var vcLevelIntimate:Vector.<int>;
		
		public function GameDefConfig()
		{
			this._data = new Dictionary();
			this._xmlDic = new Dictionary();
			if (_instance != null)
			{
				throw new Error(" GameDefConfig 单例 ");
			}
			_instance = this;
			this.init();
			
		}
		
		private function write(param1:Object) : void
		{
			var _loc_3:Object = null;
			var _loc_4:String = null;
			var _loc_5:Object = null;
			var _loc_6:DefInfo = null;
			var _loc_2:* = param1.items as Array;
			for each (_loc_3 in _loc_2)
			{
				
				_loc_4 = _loc_3.type.toString();
				for each (_loc_5 in _loc_3.item as Array)
				{
					
					_loc_6 = new DefInfo();
					_loc_6.type = _loc_4;
					_loc_6.name = _loc_5.text;
					_loc_6.id = _loc_5.id;
					_loc_6.text1 = _loc_5.text1;
					_loc_6.text2 = _loc_5.text2;
					_loc_6.value = _loc_5.value;
					this.addItem(_loc_6);
				}
				this._xmlDic[_loc_4] = _loc_3;
			}
			
		}
		
		private function addItem(param1:DefInfo) : void
		{
			this._data[param1.type + "-" + param1.id] = param1;
			
		}
		
		public function getItem(param1:String, param2:int) : DefInfo
		{
			return this._data[param1 + "-" + param2] as DefInfo;
		}
		
		public function getRewardDef(param1:int) : DefInfo
		{
			return this.getItem("reward", param1);
		}
		
		public function getEntityDef(param1:int) : DefInfo
		{
			return this.getItem("entity", param1);
		}
		
		public function getEEquipDef(param1:int) : DefInfo
		{
			return this.getItem("EEquip", param1);
		}
		
		public function getEWeaponName(param1:int) : String
		{
			var _loc_2:String = "";
			var _loc_3:* = this.getItem("EWeapon", param1);
			if (_loc_3)
			{
				_loc_2 = _loc_3.name;
			}
			return _loc_2;
		}
		
		public function getEJewel(param1:int) : DefInfo
		{
			return this.getItem("EJewel", param1);
		}
		
		public function getEBind(param1:int) : DefInfo
		{
			return this.getItem("EBind", param1);
		}
		
		public function getEPrefixx(param1:int) : DefInfo
		{
			return this.getItem("EPrefix", param1);
		}
		
		public function getECategory(param1:int) : DefInfo
		{
			return this.getItem("ECategory", param1);
		}
		
		public function getECamp(param1:int) : String
		{
			var _loc_2:String = "";
			var _loc_3:* = this.getItem("ECamp", param1);
			if (_loc_3)
			{
				_loc_2 = _loc_3.name;
			}
			return _loc_2;
		}
		
		public function getCampShort(param1:int) : DefInfo
		{
			return this.getItem("ECampShort", param1);
		}
		
		public function getSex(param1:int) : DefInfo
		{
			return this.getItem("ESex", param1);
		}
		
		public function getSkillType(param1:int) : DefInfo
		{
			return this.getItem("ESkillType", param1);
		}
		
		public function getSkillUseType(param1:int) : DefInfo
		{
			return this.getItem("ESkillUseType", param1);
		}
		
		public function init() : void
		{
			var _loc_1:* = ConfigManager.instance.getJSONByFileName("gamedef.xml");
			this.write(_loc_1.root);
			
		}
		
		public function getDefaultModel(param1:int) : DefInfo
		{
			return this.getItem("ECampModel", param1);
		}
		
		public function getEPrictUnitImg(param1:int) : String
		{
			var _loc_2:String = "";
			var _loc_3:* = this.getItem("EPrictUnitImg", param1);
			if (_loc_3)
			{
				_loc_2 = _loc_3.name;
			}
			return _loc_2;
		}
		
		public function getEPrictUnitName(param1:int) : String
		{
			var _loc_2:String = "";
			var _loc_3:* = this.getItem("EPrictUnitName", param1);
			if (_loc_3)
			{
				_loc_2 = _loc_3.name;
			}
			return _loc_2;
		}
		
		public function getEShopCode(param1:int) : int
		{
			var _loc_2:int = 0;
			var _loc_3:* = this.getItem("EShopCode", param1);
			if (_loc_3)
			{
				_loc_2 = int(_loc_3.name);
			}
			return _loc_2;
		}
		
		public function getNpcStatus(param1:int) : int
		{
			return int(this.getItem("NpcStatus", param1).name);
		}
		
		public function getCareerDes(param1:int) : String
		{
			return this.getItem("CareerDes", param1).name;
		}
		
		public function getCareerDefInfo(param1:int) : DefInfo
		{
			return this.getItem("CareerDes", param1);
		}
		
		public function getCycleReward(param1:int) : String
		{
			return this.getItem("CycleTaskReward", param1).name;
		}
		
		public function getTransportCoinReward(param1:int) : int
		{
			return int(this.getItem("TransportLevelReward", param1).text1);
		}
		
		public function getTransportLevelReward(param1:int) : String
		{
			return this.getItem("TransportLevelReward", param1).name;
		}
		
		public function getTransportColorReward(param1:int) : String
		{
			return this.getItem("TransportColorReward", param1).name;
		}
		
		public function getTransportPledge(param1:int) : String
		{
			return this.getItem("TransportPledge", param1).name;
		}
		
		public function getTransportInsure(param1:int) : String
		{
			return this.getItem("TransportPledge", param1).text1;
		}
		
		public function getGuideAutoType(param1:int) : int
		{
			return parseInt(this.getItem("GuideAutoType", param1).name);
		}
		
		public function getPositionName(param1:int) : String
		{
			return this.getItem("EGuildPosition", param1).name;
		}
		
		public function getRoleAttrDesc(param1:int) : String
		{
			return this.getItem("RoleAttrDesc", param1).name;
		}
		
		public function getPetAttrDesc(param1:int) : String
		{
			return this.getItem("PetAttrDesc", param1).name;
		}
		
		public function getLoadMapConfig(param1:int) : Array
		{
			var _loc_2:* = this.getItem("LoadMapConfig", param1);
			if (_loc_2 == null)
			{
				return null;
			}
			return _loc_2.name.split(",");
		}
		
		public function getGuildBuildingName(param1:int) : String
		{
			return this.getItem("EGuildStructureType", param1).name;
		}
		
		public function getTransportNPC() : Object
		{
			return this._xmlDic["TransportNPC"].item;
		}
		
		public function getGuildTaskNPC() : Array
		{
			return this._xmlDic["GuildTaskNPC"].item as Array;
		}
		
		public function getGuildDailyNPC() : Object
		{
			return this._xmlDic["GuildDailyNPC"].item;
		}
		
		public function getGuildFlameNPC() : Object
		{
			return this._xmlDic["GuildFlameNPC"].item;
		}
		
		public function getCopyNPCList() : Array
		{
			return this._xmlDic["CopyNpc"].item as Array;
		}
		
		public function getCopyNpc(param1:int) : Array
		{
			var _loc_2:* = this.getItem("CopyNpc", param1);
			return _loc_2.name.split(",");
		}
		
		public function getDragNPC(param1:int) : Array
		{
			var _loc_2:* = this.getItem("DragNPC", param1);
			if (_loc_2 == null)
			{
				return null;
			}
			return _loc_2.name.split(",");
		}
		
		public function getHuntNpc() : Object
		{
			return this._xmlDic["HuntNpc"].item;
		}
		
		public function getEvilNpc() : Object
		{
			return this._xmlDic["EvilNpc"].item;
		}
		
		public function getBussinessNpc() : Array
		{
			return this._xmlDic["BussinessNpc"].item as Array;
		}
		
		public function getBussinessGetNpc() : Object
		{
			return this._xmlDic["BussinessGetNpc"].item as Object;
		}
		
		public function getPetMeetStatusName(param1:int) : String
		{
			return this.getItem("PetMeetStatus", param1).name;
		}
		
		public function getGuildBuildingDesc(param1:int) : String
		{
			return this.getItem("GuildBuildingDesc", param1).name;
		}
		
		public function getGuildBuildingInfo(param1:int) : DefInfo
		{
			return this.getItem("GuildBuildingDesc", param1);
		}
		
		public function getGuildBuildingUpgradeDesc(param1:int) : String
		{
			return this.getItem("GuildBuildingDesc", param1).text1;
		}
		
		public function getGuildRewardBloom() : int
		{
			return int(this.getItem("GuildLevelExp", -1).name);
		}
		
		public function getGuildRewardContribution() : int
		{
			return int(this.getItem("GuildLevelExp", -2).name);
		}
		
		public function getGuildRewardLevelExp() : Number
		{
			return Number(this.getItem("GuildLevelExp", -3).name);
		}
		
		public function getCopyMapByCopyId(param1:int) : int
		{
			return this.getItem("CopyMap", param1) ? (int(this.getItem("CopyMap", param1).name)) : (0);
		}
		
		public function getBussinessRewardMoney() : int
		{
			return int(this.getItem("RunBuinessExp", -4).name);
		}
		
		public function getBussinessRewardBloom() : int
		{
			return int(this.getItem("RunBuinessExp", -1).name);
		}
		
		public function getBussinessRewardContribution() : int
		{
			return int(this.getItem("RunBuinessExp", -2).name);
		}
		
		public function getBussinessRewardExp() : Number
		{
			return Number(this.getItem("RunBuinessExp", -3).name);
		}
		
		public function getCareerModelCode(param1:int) : int
		{
			return int(this.getItem("CareerModel", param1).name);
		}
		
		public function getTransportInfo(param1:int) : DefInfo
		{
			return this.getItem("TransportInfo", param1);
		}
		
		public function getIntimateNameById(param1:int) : String
		{
			return this.getItem("IntimateName", param1).name;
		}
		
		public function getIntimateName(param1:int) : String
		{
			var _loc_3:int = 0;
			var _loc_2:* = this.getIntimateList();
			_loc_3 = 0;
			while (_loc_3 < _loc_2.length)
			{
				
				if (param1 < _loc_2[_loc_3])
				{
					return this.getItem("IntimateName", (_loc_3 + 1)).name;
				}
				_loc_3++;
			}
			return this.getItem("IntimateName", _loc_2.length).name;
		}
		
		public function getIntimateList() : Vector.<int>
		{
			var _loc_1:int = 0;
			if (!vcLevelIntimate)
			{
				vcLevelIntimate = new Vector.<int>;
				_loc_1 = 0;
				while (_loc_1 < 6)
				{
					
					vcLevelIntimate.push(this.getIntimate((_loc_1 + 1)));
					_loc_1++;
				}
			}
			return vcLevelIntimate;
		}
		
		public function getIntimate(param1:int) : int
		{
			return int(this.getItem("Intimate", param1).name);
		}
		
		public function getMallBuyTaskItemDes(param1:int) : String
		{
			return this.getItem("MallBuyTaskItem", param1).name;
		}
		
		public function getGroceriesNpc() : Object
		{
			return this._xmlDic["GroceriesNpc"].item as Object;
		}
		
		public static function get instance() : GameDefConfig
		{
			if (_instance == null)
			{
				_instance = new GameDefConfig;
			}
			return _instance;
		}
		
	}
}
